import React from 'react';

const getDisplayValue = (value, option) => {
  if (value === undefined || value === null) {
    return value;
  }
  return option.value === value ? option.label : option.noMatchLabel || '';
};

const Index = (props) => {
  const { value, option, render } = props;

  return (
    <>
      {render &&
        (render(getDisplayValue(value, option), {
          value,
          option,
        }) || <span>&nbsp;</span>)}
    </>
  );
};

export default Index;
